/*
	author: TangQiao , Wind @ Beijing Normal University

	problem name: Simple Computers
	
	source : PKU Online Judge
	
	problem type: 模拟题 
	
	problem description: 按题目要求模拟即可 
	
	problem solution:  模拟
	
	award & note :  注意,因为指针PC只是五位的,所以在硬件原理上说,它超过32就应该
 	自动变成0,这一点题目没有说,但是原理是这样,所以得按这样做才不会超界. 
	
	another solution: 
	
	faults: 超界了N次. 
	
	date : 2005.8.8 
	
*/
#include <stdio.h>
#include <string.h>
char  ss[34][20]; 
char  now[20];
char  head[20],tail[20],ac[20];
int pc;

int chtoint(char ch)
{
    return ch-'0';
}    

int getadd(char *s)
{
    int tot=0;
    if (chtoint(s[0])) tot+=16;
    if (chtoint(s[1])) tot+=8;
    if (chtoint(s[2])) tot+=4;
    if (chtoint(s[3])) tot+=2;
    if (chtoint(s[4])) tot+=1;
    return tot;
}
/*
int getvalue(char *s)
{
    int tot=0;
    if (chtoint(s[0])) tot+=128;
    if (chtoint(s[1])) tot+=64;
    if (chtoint(s[2])) tot+=32;
    if (chtoint(s[3])) tot+=16;
    if (chtoint(s[4])) tot+=8;
    if (chtoint(s[5])) tot+=4;
    if (chtoint(s[6])) tot+=2;
    if (chtoint(s[7])) tot+=1;
    return tot;
} */   
int equ(char *s)
{
	for (int i=0;i<8;i++)
		if (s[i]!='0')
			return 0;
	return 1;
}

int hehe(char *s1,char *s2)
{
	for (int i=0;i<3;i++)
		if (s1[i]!=s2[i])
			return 1;
	return 0;
}

main()
{


    int i, site;
    
 //   strncpy(now,"hello", 2);
 //   printf("%s", now);
//	freopen("input","r",stdin);

//    memset(head,0,sizeof(head));
 //   memset(tail,0,sizeof(tail));
 //   memset(now,0,sizeof(now));
    while (scanf("%s",ss[0])!=EOF)
    {
		for (i=1;i<=31;i++)
             scanf("%s", ss[i]);
        pc=0;
        memset(ac,0,sizeof(ac));
		for (i=0;i<8;i++) 
			ac[i]='0';
		memset(head,0,sizeof(head));
		memset(tail,0,sizeof(tail));
		memset(now,0,sizeof(now));
        while (1)
        {
            strcpy(now ,ss[pc]);
            strncpy(head, now,3);;
            strncpy(tail,now+3,5);
			pc++;
			if (pc>=32) pc=0;
            if (hehe(head,"111")==0)
            {
                break;
            }    
            else
            {                
                if (hehe(head,"000")==0) // store
                {
                    site=getadd(tail);
                //    strcpy(ss[site],ac);                    
					for (i=0;i<8;i++) ss[site][i]=ac[i];
                }    
                else if (hehe(head,"001")==0) // load
                {
                    site=getadd(tail);
                   // strcpy(ac,ss[site]);                
					for (i=0;i<8;i++) ac[i]=ss[site][i];
                }
                else if (hehe(head,"010")==0)
                {
                    if (equ(ac)==1)
                    {
                        pc=getadd(tail);
                    }    
                }
                else if (hehe(head,"011")==0)
                {
                    //nop;
                }
                else if (hehe(head,"100")==0) // dec
                {
                    ac[7]--;
                    i=7;
                    while (ac[i]!='0' && ac[i]!='1' && i>0)
                    {
                        ac[i]='1';
                        ac[i-1]--;
                        i--;
                    }    
                    if ((ac[0]!='0') && (ac[0]!='1'))
                    {
                        ac[0]='1';
                    }     
                }            
                else if (hehe(head,"101")==0) //inc
                {
                    ac[7]++;
                    i=7;
                    while (ac[i]!='0' && ac[i]!='1' && i>0)
                    {
                        ac[i]='0';
                        ac[i-1]++;
                        i--;
                    }    
                    if (ac[0]!='0' && ac[0]!='1')
                    {
                        ac[0]='0';
                    }    
                    
                }            
                else if (hehe(head,"110")==0)
                {
                    pc=getadd(tail);
                }      
				else
				{
					//while (1) ;
				}
                    
            }    
            
            
        }  // end of while   
        //printf("%s\n",ac);
		for (i=0;i<8;i++) printf("%c", ac[i]);
		printf("\n");
        
    }    
    


	return 0;
}

